import numpy as np
import matplotlib.pyplot as plt
c1="#009ad6"
c2='#f15a22'
c3='#7fb80e'
c4='#aa2116'

x=np.loadtxt('f-mle445.txt')
x1=np.loadtxt('f-pe445.txt')
x2=np.loadtxt('f-pm445.txt')
x3=np.loadtxt('f-map445.txt')

for i in range(2):
    x[:,i+1]=x[:,i+1]/x[:,0]
    x1[:,i+1]=x1[:,i+1]/x1[:,0]
    x2[:,i+1]=x2[:,i+1]/x2[:,0]
    x3[:,i+1]=x3[:,i+1]/x3[:,0]
x[:,0]=2922/x[:,0]
x1[:,0]=2922/x1[:,0]
x2[:,0]=2922/x2[:,0]
x3[:,0]=2922/x3[:,0]

plt.figure(dpi=150)
plt.plot(x[:,0],np.ones(len(x[:,0])),'k')

plt.plot(x[:,0],x[:,1],color=c2,label=r'$\bar{\tau}_{MLE}$')
#plt.plot(x[:,0],x[:,1]+x[:,2],'--',color=c2,label=r'$\sigma_G(\tau_{MLE})$')
#plt.plot(x[:,0],x[:,1]-x[:,2],'--',color=c2)

plt.plot(x1[:,0],x1[:,1],color=c1,label=r'$\bar{\tau}_{PE}$')
#plt.plot(x1[:,0],x1[:,1]+x1[:,2],'--',color=c1,label=r'$\sigma_G(\tau_{PE})$')
#plt.plot(x1[:,0],x1[:,1]-x1[:,2],'--',color=c1)

plt.plot(x2[:,0],x2[:,1],color=c3,label=r'$\bar{\tau}_{PM}$')
#plt.plot(x2[:,0],x2[:,1]+x2[:,2],'--',color=c3,label=r'$\sigma_G(\tau_{PM})$')
#plt.plot(x2[:,0],x2[:,1]-x2[:,2],'--',color=c3)

plt.plot(x3[:,0],x3[:,1],color=c4,label=r'$\bar{\tau}_{MAP}$')
#plt.plot(x3[:,0],x3[:,1]+x3[:,2],'--',color=c4,label=r'$\sigma_G(\tau_{MAP})$')
#plt.plot(x3[:,0],x3[:,1]-x3[:,2],'--',color=c4)

plt.xscale('log')
plt.xlabel(r'$T/\tau_{in}$')
plt.ylabel(r'$\tau_{out}/\tau_{in}$')
plt.title(r'different estimates(N=445,Error=OGLE)')
plt.xlim(1,1000)
plt.grid()
plt.ylim(0,1.5)
plt.legend(fontsize=9)
plt.show()

